home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / fcntl.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  2.7 KB  |  112 lines

  1. #
  2. # fcntl.test
  3. #
  4. # Tests for the fcntl command.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: fcntl.test,v 3.0 1993/11/19 06:57:20 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. set testFH [open FCNTL.TMP w]
  22. close $testFH
  23.  
  24. set testFH [open FCNTL.TMP r+]
  25.  
  26. pipe testRPH testWPH
  27.  
  28. Test fcntl-1.1 {fcntl tests} {
  29.     fcntl $testFH RDWR
  30. } 0 1
  31.  
  32. Test fcntl-1.2 {fcntl tests} {
  33.     fcntl $testFH READ
  34. } 0 1
  35.  
  36. Test fcntl-1.3 {fcntl tests} {
  37.     fcntl $testFH WRITE
  38. } 0 1
  39.  
  40. Test fcntl-1.4 {fcntl tests} {
  41.     fcntl $testFH CLOEXEC 1
  42.     fcntl $testFH CLOEXEC
  43. } 0 1
  44.  
  45. Test fcntl-1.5 {fcntl tests} {
  46.     fcntl $testFH CLOEXEC 0
  47.     fcntl $testFH CLOEXEC
  48. } 0 0
  49.  
  50. Test fcntl-1.6 {fcntl tests} {
  51.     fcntl $testRPH NONBLOCK 1
  52.     fcntl $testRPH NONBLOCK
  53. } 0 1
  54.  
  55. Test fcntl-1.7 {fcntl tests} {
  56.     fcntl $testFH append 1
  57.     fcntl $testFH append
  58. } 0 1
  59.  
  60. Test fcntl-1.8 {fcntl tests} {
  61.     fcntl $testFH APPEND 0
  62.     fcntl $testFH append
  63. } 0 0
  64.  
  65. Test fcntl-1.9 {fcntl tests} {
  66.     fcntl $testRPH NONBLOCK 0
  67.     fcntl $testRPH nonBlock
  68. } 0 0
  69.  
  70. Test fcntl-1.10 {fcntl tests} {
  71.     fcntl $testFH NOBUF 1
  72.     fcntl $testFH NObuf
  73. } 0 1
  74.  
  75. Test fcntl-1.11 {fcntl tests} {
  76.     fcntl $testFH NOBUF 0
  77. } 1 {Attribute "NOBUF" may not be cleared once set}
  78.  
  79. close $testFH
  80. set testFH [open FCNTL.TMP w]  ;# Reopen, can not have both nobuf and linebuf
  81.  
  82. Test fcntl-1.12 {fcntl tests} {
  83.     fcntl $testFH LINEBUF 1
  84.     fcntl $testFH LINEBUF
  85. } 0 1
  86.  
  87. Test fcntl-1.13 {fcntl tests} {
  88.     fcntl $testFH LINEBUF 0
  89. } 1 {Attribute "LINEBUF" may not be cleared once set}
  90.  
  91. Test fcntl-1.14 {fcntl tests} {
  92.     fcntl $testFH a b c
  93. } 1 {wrong # args: fcntl handle attribute ?value?}
  94.  
  95. Test fcntl-1.15 {fcntl tests} {
  96.     fcntl $testFH BAZ 1
  97. } 1 {unknown attribute name "BAZ", expected one of APPEND, CLOEXEC, LINEBUF, NONBLOCK, NOBUF, READ, RDONLY, RDWR, WRITE, WRONLY}
  98.  
  99. Test fcntl-1.16 {fcntl tests} {
  100.     fcntl $testFH APPEND FOO
  101. } 1 {expected boolean value but got "FOO"}
  102.  
  103. close $testFH
  104.  
  105. Test fcntl-1.15 {fcntl tests} {
  106.     fcntl $testFH RDONLY
  107. } 1 "file \"$testFH\" isn't open"
  108.  
  109. close $testRPH
  110. close $testWPH
  111. unlink FCNTL.TMP
  112.